import type { TableProps } from "antd/lib"
import type { ColumnType } from "antd/es/table"
import { type ButtonProps } from "antd"
import type React from "react";
export interface OperationType<T = any> {
    label: string;
    key: string;
    show?: boolean | ((record: T, index: number) => boolean);
    buttonProps?: ButtonProps;
}

export type TableOption = {
    show: boolean;
    onClick?: () => void;
}

export type ToolBarOptions = {
        setting?: TableOption;
        print?: TableOption;
        outPut?: TableOption;
        batch?: BatchOption;
    }

export type BatchOption = {
    onClick?: (selectedRows: any[],key:string) => void;
    show?: boolean;
    dropDownOptions?: Array<{
        label: string;
        key: string;
        icon?:React.ReactNode
        // onClick?: (selectedRowKeys: React.Key[], selectedRows: any[]) => void;
    }>
}

export interface ColumnPlusType<T = any> extends ColumnType<T> {
    operations?: OperationType<T>[],
    operateClick?: (key: string, record: T) => void
}

export interface TablePlusProps<T = any> extends Omit<TableProps<T>, 'columns'> {
    columns: ColumnPlusType<T>[],
    request?: (params: Record<string, any>) => Promise<{ data: T[]; success: boolean; total: number }>;
    dataSource?: T[]; // 如果传入了 dataSource 则不走 request 请求
    toolBarRender?: () => React.ReactNode; // 自定义工具栏
    options?: ToolBarOptions;
    loading?: boolean;
    params?: Record<string, any>;
    tableHeaderTitle?:string;
    pagination?: {
        pageSize?: number;
        current?: number;
        total?: number;
        showSizeChanger?: boolean;
        showQuickJumper?: boolean;
        onChange?: (page: number, pageSize: number) => void;
    } | false;
}

